package com.campus.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 商家进度枚举
 */
@Getter
@AllArgsConstructor
public enum MerchantProcessEnum {

    /**
     * 待接单
     */
    PENDING_ACCEPTANCE(0, "待接单"),

    /**
     * 备餐中
     */
    PREPARING_MEAL(1, "备餐中"),

    /**
     * 已出餐
     */
    MEAL_READY(2, "已出餐");

    @EnumValue
    @JsonValue
    private final Integer value;
    private final String text;

    public static String getTextByValue(Integer value) {
        for (MerchantProcessEnum status : values()) {
            if (status.getValue().equals(value)) {
                return status.getText();
            }
        }
        return null;
    }

    public static MerchantProcessEnum getByValue(Integer value) {
        for (MerchantProcessEnum temp : MerchantProcessEnum.values()) {
            if (temp.getValue().equals(value)) {
                return temp;
            }
        }
        return null;
    }
}